{{$cw := .curWeek}}
{{$ct := .curTime}}
<h1>每日签到</h1>
<div class="week">
    <ul>
        {{range $k,$v := .weeks}}
            <li>
                <div class="week_name">{{$v}}</div>
                <div class="week_num {{if eq $k $cw}}active{{end}}">{{$k}}</div>
            </li>
        {{end}}
    </ul>
</div>
<div class="main">
    <div class="time">
        <ul>
            {{range $k,$v := .times}}
                <li {{if eq $v $ct}}class="active"{{end}}>{{$v}}</li>
            {{end}}
        </ul>
    </div>
    <div class="operate">
        <div class="box">
            <form id="morning" action="/punch/{{.id}}" method="post">
                <input type="hidden" name="morning" value="1">
                <div {{if eq .morning 0}}onclick="submit('morning')"{{end}} class="operate_btn p1">
                    <div class="done {{if ne .morning 0}}active{{end}}">
                        {{if ne .morning 0}}
                            早间 . 已签到
                        {{else}}
                            早间 . 未签到
                        {{end}}
                    </div>
                </div>
            </form>
            <form id="noon" action="/punch/{{.id}}" method="post">
                <input type="hidden" name="noon" value="1">
                <div {{if eq .noon 0}}onclick="submit('noon')"{{end}} class="operate_btn p2">
                    <div class="done {{if ne .noon 0}}active{{end}}">
                        {{if ne .noon 0}}
                            午间 . 已签到
                        {{else}}
                            午间 . 未签到
                        {{end}}
                    </div>
                </div>
            </form>
            <form id="night" action="/punch/{{.id}}" method="post">
                <input type="hidden" name="night" value="1">
                <div {{if eq .night 0}}onclick="submit('night')"{{end}} class="operate_btn p3">
                    <div class="done {{if ne .night 0}}active{{end}}">
                        {{if ne .night 0}}
                            晚间 . 已签到
                        {{else}}
                            晚间 . 未签到
                        {{end}}
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    function o(name) {
        return document.getElementById(name);
    }

    function submit(name) {
        var msg = {
            "morning": "确认早间打卡？",
            "noon": "确认午间打卡？",
            "night": "确认晚间打卡？",
        }
        if(confirm(msg[name])) {
            o(name).submit();
        }
    }
</script>